#include <iostream>
using namespace std;
bool check(int a,int b,int c){
	bool flag  = 0;
	if(b == 0 || c == 0) return 0;
	if(b > 12) return 0;
	if((a % 100 != 0 && a % 4 == 0) || a % 400 == 0) flag = 1;
	if(b == 4 || b == 6 || b == 9 || b == 11){
		if( c > 30){
			return 0;
		}
	}else if( b == 2 )
	{
		if(flag == 0) 
			{if(c >28) return 0;}
		else if(flag == 1){
			if(c > 29) return 0;			
		}
	}else{
		if(c > 31) return 0;
	}
	return 1;
}
int main()
{
	// 请在此输入您的代码
	int a,b,c;
	scanf("%2d/%2d/%2d",&a,&b,&c);
	for(int i = 19600101;i<=20591231;i++)
	{
		int year = i /10000, mon = i % 10000 /100,day = i %100;
		int ta = year%100;
		if(check(year,mon,day)){
			if((a == ta && b == mon && c == day) || (a == mon && b == day && c == ta) || ( a == day && b == mon && c == ta ) )
				printf("%4d-%02d-%02d\n",year,mon,day);
		}
	}
	return 0;
} 
